package com.whc.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.system.common.pojo.BisBusinessOrder;
import com.system.common.pojo.BisShopUser;
import com.whc.service.BisBusinessOrderService;


@Controller
@RequestMapping("bis")
public class BisBusinessOrderController {
	
	@Autowired
	private BisBusinessOrderService orderService;
	
	@RequestMapping("listAll")
	public String listAll(Model model,HttpServletRequest request,HttpSession session){
		Map<String, Object> map=mmxx(request);
		BisShopUser shopUser=(BisShopUser) session.getAttribute("shopUser");
		map.put("shopId", shopUser.getShopId());
		List<BisBusinessOrder> list=orderService.selectAll(map);		
		model.addAttribute("list",list);	
		return "business.whc/bisBusinessOrderList";
	}
	
	@RequestMapping("all")//全部记录
	public String all(Model model,HttpServletRequest request,HttpSession session){
		Map<String, Object> map=mmxx(request);
		BisShopUser shopUser=(BisShopUser) session.getAttribute("shopUser");
		map.put("shopId", shopUser.getShopId());
		List<BisBusinessOrder> list=orderService.selectAll(map);
		model.addAttribute("list",list);		
		return "business.whc/test1";
	}
	
	@RequestMapping("selectAll")//消耗记录
	public String list(Model model,HttpServletRequest request,HttpSession session){
		Map<String, Object> map=mmxx(request);
		BisShopUser shopUser=(BisShopUser) session.getAttribute("shopUser");
		map.put("shopId", shopUser.getShopId());
		List<BisBusinessOrder> list=orderService.selectAll(map);
		model.addAttribute("list",list);		
		return "business.whc/test2";
	}
	
	@RequestMapping("select")//颜值记录
	public String select(Model model,HttpServletRequest request){
		Map<String, Object> map=mmxx(request);
		List<BisBusinessOrder> list=this.orderService.selectAll(map);
		model.addAttribute("list",list);		
		model.addAttribute("shops", orderService.listAllShop());		
		return "business.whc/test3";
	}
	
	
	public Map<String, Object> mmxx(HttpServletRequest request){
		Map<String, Object> map =new HashMap<>();
		String orderId = request.getParameter("orderId");//定义变量
		String phone=request.getParameter("phone");
		String shopname=request.getParameter("shopname");
		String payWay=request.getParameter("payWay");
		String project=request.getParameter("project");
		String orderStatus=request.getParameter("orderStatus");		
		String username=request.getParameter("username");
		
		if (orderId!=null&&!orderId.equals("")) {
			map.put("orderId", orderId);//订单编号
		}
		if (phone!=null&&!phone.equals("")) {
			map.put("phone",phone);//顾客账号
		}
		if (shopname!=null&&!shopname.equals("")) {
			map.put("shopname", shopname);//顾客姓名
		}
		if (payWay!=null&&!payWay.equals("")) {
			map.put("payWay", payWay);//支付方式
		}
		if (project!=null&&!project.equals("")) {
			map.put("project", project);//消费内容
		}
		if (orderStatus!=null&&!orderStatus.equals("")) {
			map.put("orderStatus", orderStatus);//订单状态
		}
		
		if (username!=null&&!username.equals("")) {
			map.put("username", username);//服务员工
		}
		
		String jsTime = request.getParameter("jsTime");
		if(jsTime!=null&&jsTime!=""){
			map.put("jsTime", jsTime);
		}
		String zfTime = request.getParameter("zfTime");
		if(zfTime!=null&&zfTime!=""){
			map.put("zfTime", zfTime);
		}
		
		
		return map;
	}

}
